package com.lu.pojo.thread.status;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author luzhenfang
 * @date 2020 05 23
 * @description 线程休眠
 * sleep 不会释放锁
 */
public class ThreadSleep {
    public static void tenDown(){
        int num =10;
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(num--);
            if(num<0){
                break;
            }
        }
    }

    public static void main(String[] args) {
        tenDown();
        // 获取当前时间
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Date date = new Date(System.currentTimeMillis());
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(date));
        }
    }
}
